import {defineStore} from "pinia";
import {useSearchSuggest} from "@/API/api";
import type {SearchSuggest} from "@/models/search";

export const useSearchStore = defineStore('search', {
    state: () => {
        return {
            showSearchView: false,
            searchKeyword: '', //搜索关键字
            suggestData: {} as SearchSuggest,
        }
    },
    getters: {
        showHot: state => {  //是否隐藏
            return state.searchKeyword == ''
        }
    },
    actions: {
        async suggest() {
            this.suggestData = await useSearchSuggest(this.searchKeyword);
        }
    }
});
